package seo.dale.util.database;

import org.apache.commons.lang3.*;

public class LikeSearchUtils {

	/**
	 * Insert % to the query for like search. 
	 */
	public static String forLikeSearch(String query) {
		StringBuilder builder = new StringBuilder("%");
		String[] tokens = StringUtils.split(query, ",");
		
		if (ArrayUtils.isNotEmpty(tokens)) {
			for (String t : tokens) {
				t = StringUtils.trimToNull(t);
				if (t != null) {
					builder.append(t).append("%");	
				}
			}
		}
				
		return builder.toString();
	}
	
}
